package com.usian.skill.mq;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class MqSender {

    @Autowired
    AmqpTemplate amqpTemplate;

    public void sendmiaoshaMessage(Object mm){
        //将mm转换成json数据
        String j = JSON.toJSONString(mm);
        log.info("send message:"+j);
        //发送消息
        amqpTemplate.convertAndSend(MQConfig.QUEUE,j);
    }
    //声明的发送秒杀的信息
    public void sendSkillMessage(SkillMessage smg){
        String json = JSON.toJSONString(smg);
        amqpTemplate.convertAndSend(MQConfig.SkillQUEUE,json);
    }
}
